﻿#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;


void test_01()
{
	vector<int>array;
	array.push_back(100);
	array.push_back(300);
	array.push_back(300);
	array.push_back(300);
	array.push_back(300);
	array.push_back(500);
	vector<int>::iterator itor;
	for (itor = array.begin(); itor != array.end(); itor++)
	{
		if (*itor == 300)
		{
			itor = array.erase(itor);
		}
	}
	for (itor = array.begin(); itor != array.end(); itor++)
	{
		cout << *itor << " ";
	}
}

struct A
{
public:
	A(int a1 = 1, int a2 = 1)
		:_a1(a1)
		,_a2(a2)
	{
		cout << "A(int a1 = 1, int a2 = 1)" << endl;
	}
	A(const A& aa)
		:_a1(aa._a1)
		,_a2(aa._a2)
	{
		cout << "A(const A& aa)" << endl;
	}

	int _a1;
	int _a2;
};
void test_02()
{
	list<int> lt;
	lt.push_back(6);
	lt.push_back(4);
	lt.push_back(3);
	lt.push_back(2);
	list<int>::iterator it = lt.begin();
	while (it != lt.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;

	lt.sort();
	for (auto e : lt)
	{
		cout << e << " ";
	}
	cout << endl;
	//升序
	//lt,sort();
	//降序---仿函数
	//less<int> ls;
	//greater<int> gt;
	lt.sort(greater<int>());
	for (auto e : lt)
	{
		cout << e << " ";
	}
	cout << endl;
	list<A> lt2;
	A aa1(1, 1);
	lt2.push_back(aa1);
	lt2.push_back(A(2, 2));
	//lt2.push_back(3, 3);  不可
	lt2.emplace_back(3, 3);
	cout << endl;
}

void test_03()
{
	list<int> lt;
	lt.push_back(1);
	lt.push_back(20);
	lt.push_back(3);
	lt.push_back(5);
	lt.push_back(4);
	lt.push_back(5);
	lt.push_back(6);

	list<double> first, second;

	first.push_back(3.1);
	first.push_back(2.2);
	first.push_back(2.9);

	second.push_back(3.7);
	second.push_back(7.1);
	second.push_back(1.4);

	first.sort();
	second.sort();

	first.merge(second);

	for (auto e : first)
	{
		cout << e << " ";
	}
	cout << endl;
	for (auto e : second)
	{
		cout << e << " ";
	}
	cout << endl;
}
int main()
{
	//test_01();
	//test_02();
	test_03();
	return 0;
}